
package com.ffcs.crmd.tsp.admin.facade.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ctg.itrdc.platform.common.entity.PageInfo;
import com.ctg.itrdc.platform.common.utils.bean.BeanUtils;
import com.ffcs.crmd.platform.core.ddd.facade.impl.AbstractCrmDomFacade;
import com.ffcs.crmd.tsp.admin.api.dto.TaskIdentityDTO;
import com.ffcs.crmd.tsp.admin.api.facade.ITaskIdentityFacade;
import com.ffcs.crmd.tsp.admin.entity.TaskIdentity;
import com.ffcs.crmd.tsp.admin.service.ITaskIdentityService;

@Service("taskIdentityFacade")
public class TaskIdentityFacadeImpl extends AbstractCrmDomFacade implements ITaskIdentityFacade {
   	
   	@Autowired
	private ITaskIdentityService taskIdentityService;
	   
   	
   	private PageInfo<TaskIdentityDTO> copyPageInfo(PageInfo<TaskIdentity> pageInfo) throws Exception{
        PageInfo<TaskIdentityDTO> pageInfoDto = new PageInfo<TaskIdentityDTO>();
        BeanUtils.applyIf(pageInfoDto, pageInfo, false);
        pageInfoDto.setList(BeanUtils.copyList(pageInfo.getList(), TaskIdentityDTO.class));
        return pageInfoDto;
    }
   	
	@Override
    public TaskIdentityDTO get(TaskIdentityDTO taskIdentityDTO) throws Exception {
        TaskIdentity taskIdentity = new TaskIdentity();
        BeanUtils.applyIf(taskIdentityDTO, taskIdentity, false);
        TaskIdentity rtaskIdentity = taskIdentityService.get(taskIdentity);
        
        TaskIdentityDTO rtaskIdentityDTO = new TaskIdentityDTO();
        BeanUtils.applyIf(rtaskIdentityDTO, rtaskIdentity, false);
        return rtaskIdentityDTO;
    }
    
    /**
     * 功能说明:
     * 
     * @param clusterName
     * @param identity
     * @param jobId
     * @return
     * @throws Exception
     */
    @Override
    public List<TaskIdentityDTO> query(TaskIdentityDTO taskIdentityDTO) throws Exception {
        TaskIdentity taskIdentity = new TaskIdentity();
        BeanUtils.applyIf(taskIdentity, taskIdentityDTO, false);
        List<TaskIdentity> TaskIdentityList = taskIdentityService.query(taskIdentity);
        return BeanUtils.copyList(TaskIdentityList, TaskIdentityDTO.class);
    }
    
    /**
     * 功能说明:
     * 
     * @param clusterName
     * @param identity
     * @param jobId
     * @param pageNumber
     * @param pageSize
     * @return
     * @throws Exception
     */
    @Override
    public PageInfo<TaskIdentityDTO> queryPage(TaskIdentityDTO taskIdentityDTO) throws Exception {
        TaskIdentity taskIdentity = new TaskIdentity();
        BeanUtils.applyIf(taskIdentity, taskIdentityDTO, false);
        PageInfo<TaskIdentity> pageInfo = taskIdentityService.queryPage(taskIdentity, taskIdentityDTO.getPageNumber(), taskIdentityDTO.getPageSize());
        return copyPageInfo(pageInfo);
    }
    
    @Override
    public void remove(List<TaskIdentityDTO> TaskIdentityDTOList) throws Exception {
        List<TaskIdentity> TaskIdentityList = BeanUtils.copyList(TaskIdentityDTOList, TaskIdentity.class);
        taskIdentityService.deleteTaskIdentity(TaskIdentityList);
    }

    @Override
    public void remove(TaskIdentityDTO TaskIdentityDTO) throws Exception {
        TaskIdentity TaskIdentity = new TaskIdentity();
        BeanUtils.applyIf(TaskIdentity, TaskIdentityDTO, false);
        taskIdentityService.deleteTaskIdentity(TaskIdentity);
    }

    @Override
    public void save(TaskIdentityDTO taskIdentityDTO) throws Exception {
        TaskIdentity taskIdentity = new TaskIdentity();
        BeanUtils.applyIf(taskIdentity, taskIdentityDTO, false);
        taskIdentityService.saveTaskIdentity(taskIdentity);
    }
    
    
    @Override
    public void update(TaskIdentityDTO TaskIdentityDTO) throws Exception {
        TaskIdentity taskIdentity = new TaskIdentity();
        BeanUtils.applyIf(taskIdentity, TaskIdentityDTO, false);
        taskIdentityService.updateTaskIdentity(taskIdentity);
    }
}
